﻿/*文件注释
 * ===============================================================================
 * 说明：
 * 作者：曾永佑
 * 版本：V1.0
 * 创建日期：2013-11-1
 * 完成日期： 
 * 修改纪录：  
 * ===============================================================================
 */ 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SRF.Components.Logging
{
    public class UrlRequestLogger : SRF.Common.Logging.IUrlRequestLogger
    {
        readonly Data.DBHelperBase dbhelper = Data.DBHelperFactory.GetDBHelper();
        const string InsertLogSQL = "admin.urlrequestlog.insert";

        public UrlRequestLogger()
        {
        }

        public void Write(System.Web.HttpRequestBase request, string userId)
        { 
            dbhelper.GetQuery(InsertLogSQL).SetParameter(new
            {
                UserId = userId,
                Url = request.Url.ToString(),
                Ip = request.UserHostAddress,
                Browser = request.Browser.Type,
                RequestTime = DateTime.Now
            }).Execute();
        }
    }
}